#ifndef	__BFX_REF_UNITEXTREADER_H__
#define	__BFX_REF_UNITEXTREADER_H__

namespace BFX
{

// This abstract base class represents a reader that can read a sequential stream of characters.
class BFX_API REFUniTextReader : public REFObject
{
public:
	REFUniTextReader();
	virtual ~REFUniTextReader();

	// Closes this textreader and releases any system resources associated with the textreader.
	virtual void Close() {}
	// Returns the next available character without actually reading it from the input stream.
	// The current position of the TextReader is not changed by this operation.
	// The returned value is -1 if no further characters are available.
	virtual int Peek() = 0;
	// Reads the next character from the input stream
	// The returned value is -1 if no further characters are available.
	virtual int Read() = 0;
	// Reads a block of characters.
	// This method will read up to count characters from this textreader into the buffer character array starting at position index.
	// Returns the actual number of characters read.
	virtual int Read(OUT UCHAR* pBuffer, int iOffset, int nLength);
};

class BFX_API REFUniStringReader : public REFUniTextReader
{
public:
	REFUniStringReader(const UniString& str);
	virtual ~REFUniStringReader();

	// Returns the next available character without actually reading it from the input stream.
	// The current position of the TextReader is not changed by this operation.
	// The returned value is -1 if no further characters are available.
	virtual int Peek();
	// Reads the next character from the input stream
	// The returned value is -1 if no further characters are available.
	virtual int Read();
	// Reads a block of characters.
	// This method will read up to count characters from this textreader into the buffer character array starting at position index.
	// Returns the actual number of characters read.
	virtual int Read(OUT UCHAR* pBuffer, int iOffset, int nLength);

private:
	UniString	m_str;
	int	m_nPos;
};

}	//	namespace BFX

#endif	//	__BFX_REF_UNITEXTREADER_H__
